package JUC.AQS.concurrent.TestDemo;



import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author CKC
 * @DateTime 2021/8/24 16:03
 */
public class LockDemo {
    private static ReentrantLock lock = new ReentrantLock();
    private static Condition condition1 = lock.newCondition();
    private static Condition condition2 = lock.newCondition();

    public static void main(String[] args) {

        new Thread(() -> {
            method1();
        }, "t1").start();
        method2();
    }

    public static void method1() {
        lock.lock();
        try {
            System.out.println(Thread.currentThread().getName() + "----");
        } finally {
            lock.unlock();
        }
    }

    public static void method2() {
        lock.lock();
        try {
            System.out.println(Thread.currentThread().getName() + "+++++++");
        } finally {
            lock.unlock();
        }
    }

}
